<template>
  <div class="container">
    <div class="header">
      <van-nav-bar title="员工大厅" left-text="返回" left-arrow @click-left="onClickLeft" class="header"  />
    </div>
    <van-search v-model="value"
      background="linear-gradient(180deg, rgba(195, 207, 226, 1) 0%, rgba(245, 247, 250, 1) 100%)" show-action
      placeholder="请输入搜索关键词" input-align="center" @search="onSearch">
      <template #action>
        <div @click="onClickButton">搜索</div>
      </template>
    </van-search>
    <div class="list">
      <div v-for="(item, index) in staffList" :key="index" class="list-item" @click="goToDetail(item)">
        <img :src="item.avatar" alt="头像" class="avatar" />
        <div class="item-info">
          <div class="name-performance">
            <span class="name">{{ item.name }}</span>
            <span class="performance">绩效: {{ item.performance }}</span>
          </div>
          <span class="status">{{ item.status }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const onClickLeft = () => history.back();
const router = useRouter()
const staffList = ref([
  {
    id: 1,
    avatar: 'src/assets/avatar.jpg',
    name: '小哥一号',
    status: '空闲',
    performance: '8.75'
  },
  {
    id: 2,
    avatar: 'src/assets/avatar.jpg',
    name: '小哥二号',
    status: '接单中',
    performance: '9.20'
  }
])

const goToDetail = (item) => {
  router.push(`/employee?id=${item.id}`)
}
</script>

<style scoped>
.container {
  background: linear-gradient(180deg, rgba(195, 207, 226, 1) 0%, rgba(245, 247, 250, 1) 100%);
  min-height: 100vh;
}

.header {
  background-color: #4050B5;
  height: 50px;
}

.title {
  flex-grow: 1;
  color: #fff;
  text-align: center;
  font-size: 18px;
  margin: 0;
  letter-spacing: 10px;
}

.list {
  margin: 10px 10px;
}

.list-item {
  background-color: #fff;
  margin: 20px 0;
  padding: 20px;
  border-radius: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-right: 15px;
}

.item-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.name-performance {
  display: flex;
  flex-direction: column;
}

.name {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.performance {
  font-size: 14px;
  color: #4050B5;
  font-weight: bold;
}

.status {
  font-size: 18px;
  font-weight: bold;
  color: #666;
  align-self: center;
}
</style>
